package net.zjitc.common;


import org.apache.poi.ss.formula.functions.T;

/**
 * @Author admin
 * @DATE 2019/3/28 15:08
 */
public class ResultMessage<T> {
    private int status;
    private String message;
    private T data;

    public ResultMessage(int status) {
        this.status = status;
    }

    public ResultMessage(int status, String message) {
        this.status = status;
        this.message = message;
    }

    public ResultMessage(int status, T data) {
        this.status = status;
        this.data = data;
    }

    public ResultMessage(int status, String message, T data) {
        this.status = status;
        this.message = message;
        this.data = data;
    }

    public int getStatus() {
        return status;
    }

    public String getMessage() {
        return message;
    }

    public T getData() {
        return data;
    }



    public static <T> ResultMessage createSuccessMessage(){
        return new ResultMessage<T>(ResponseCode.SUCCESS.getCode());
    }

    public static <T> ResultMessage createSuccessMessage(String message){
        return new ResultMessage<T>(ResponseCode.SUCCESS.getCode(),message);
    }
    public static <T>  ResultMessage createSuccessMessage(T data){
        return new ResultMessage<T>(ResponseCode.SUCCESS.getCode(),data);
    }
    public static <T> ResultMessage createSuccessMessage(String message,T data){
        return new ResultMessage<T>(ResponseCode.SUCCESS.getCode(),message,data);
    }


    public static <T> ResultMessage createErrorMessage(){
        return new ResultMessage<T>(ResponseCode.SUCCESS.getCode());
    }

    public static <T> ResultMessage createErrorMessage(String message){
        return new ResultMessage<T>(ResponseCode.SUCCESS.getCode(),message);
    }
    public static <T>  ResultMessage createErrorMessage(T data){
        return new ResultMessage<T>(ResponseCode.SUCCESS.getCode(),data);
    }
    public static <T> ResultMessage createErrorMessage(String message,T data){
        return new ResultMessage<T>(ResponseCode.SUCCESS.getCode(),message,data);
    }

}

